package com.yxc.elasticsearchdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
import org.springframework.data.mapping.context.MappingContext;

/**
 * 将重写的CustomMappingEsConverter类注册到Bean
 */
@Configuration
public class MappingEsConfiguration {

    @Bean
    @Primary
    public CustomMappingEsConverter CustomMappingElasticsearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext,
                                                                        GenericConversionService genericConversionService) {
        return new CustomMappingEsConverter(mappingContext, genericConversionService);
    }
}
